<template>
  <div class="all">
    <div class="live-place-container">
      <div class="title-box">
        <h3 class="title">风险变化动态统计</h3>
        <ul class="fTab">
          <li
            @click="tabClick(index)"
            v-for="(item, index) in dateList"
            :class="{'seletedTab': isActive == index}"
            :key="index"
          >{{item}}</li>
        </ul>
      </div>

      <div class="tr-item live-header">
        <div class="col-3">风险等级</div>
        <div class="col-3">新增风险</div>
        <div class="col-3">接触风险</div>
        <div class="col-3">当前风险</div>
      </div>
      <div class="tr-item" v-for="p in live">
        <div class="col-3">{{ p.name }}</div>
        <div class="col-3">{{ p.addCount }}</div>
        <div class="col-3">{{ p.delCount }}</div>
        <div class="col-3">{{ p.curCount }}</div>
      </div>
    </div>
    <div class="box2">
      <echarts2 id="echartsd1" :option="option1" :styles="styles1"></echarts2>
    </div>
  </div>
</template>

<script>
import echarts from "echarts";
import echarts2 from "@/components/echarts.vue";

export default {
  name: "Seven",
  props: {
    chartDataOne1: {
      type: Array,
      default: () => {
        return [];
      }
    },
    chartDataOne2: {
      type: Array,
      default: () => {
        return [];
      }
    },
    chartDataOne3: {
      type: Array,
      default: () => {
        return [];
      }
    },
    chartDataOne4: {
      type: Array,
      default: () => {
        return [];
      }
    },
    nameList: {
      type: Array,
      default: () => {
        return [];
      }
    },
    liveData: {
      type: Array,
      default: () => {
        return [];
      }
    }
  },
  data() {
    var colors = ["#7cf317", "#d10eb1", "#4ddbff"];

    return {
      isActive: 0,
      dateList: ["今日", "本周", "本月"],
      live: this.liveData,
      styles1: {
        width: "100%",
        height: "100%",
        margin: "0 auto"
      },
      //
      option1: {
        barWidth: 10,
        // barGap:'80%',
        // "splitLine": {     //网格线
        //   "show": false
        // },
        title: {
          text: "风险动态变化统计",
          color: "#fff",
          left: 5,
          textStyle: {
            color: "#fff",
            fontSize: 14
          }
        },
        xAxis: {
          // show : false,
          boundaryGap: false,
          type: "category",
          data: this.nameList,
          axisTick: {
            show: false
          },
          // position: 'b',
          // 去掉y轴坐标线
          axisLine: {
            show: false
          },
          // 设置字体
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
              fontSize: 12
            }
          }
        },
        legend: {
          textStyle: {
            color: "#fff"
          },
          icon: "roundRect", //  字段控制形状  类型包括 circle，rect,line，roundRect，triangle，diamond，pin，arrow，none
          itemWidth: 12, // 设置宽度
          itemHeight: 4, // 设置高度
          itemGap: 12, // 设置间距
          top: 30,
          right: 10,
          data: ["I 级风险", "II 级风险", "III 级风险", "IV 级风险"]
        },
        series: [
          {
            name: "I 级风险",
            type: "line",
            data: this.chartDataOne1,
            symbol: "circle", //折点设定为实心点
            symbolSize: 8,
            itemStyle: {
              normal: {
                barBorderRadius: [3, 3, 0, 0],
                color: "#D32F30",
                lineStyle: {
                  color: "#D32F30" //折线颜色
                }
              }
            }
          },
          {
            name: "II 级风险",
            type: "line",
            // data: [30, 1100, 200, 900, 1100, 400, 300],
            data: this.chartDataOne2,
            symbol: "circle", //折点设定为实心点
            symbolSize: 8, //设定实心点的大小
            itemStyle: {
              normal: {
                barBorderRadius: [10, 10, 0, 0],
                color: "#F28C1D",
                lineStyle: {
                  color: "#F28C1D" //折线颜色
                }
              }
            }
          },
          {
            name: "III 级风险",
            type: "line",
            // data: [60, 700, 400, 800, 100, 700, 1100],chartDataOne1
            data: this.chartDataOne3,
            symbol: "circle", //折点设定为实心点
            symbolSize: 8, //设定实心点的大小
            itemStyle: {
              normal: {
                barBorderRadius: [10, 10, 0, 0],
                color: "#FFF45C",
                lineStyle: {
                  color: "#FFF45C" //折线颜色
                }
              }
            }
          },
          {
            name: "IV 级风险",
            type: "line",
            // data: [60, 700, 400, 800, 100, 700, 1100],
            data: this.chartDataOne4,
            symbol: "circle", //折点设定为实心点
            symbolSize: 8, //设定实心点的大小
            itemStyle: {
              normal: {
                barBorderRadius: [10, 10, 0, 0],
                color: "#0041FB",
                lineStyle: {
                  color: "#0041FB" //折线颜色
                }
              }
            }
          }
        ],
        // 设置图标的位置
        grid: {
          x: 20,
          x2: 30,
          // y:10,
          y2: 0,
          containLabel: true
        },
        yAxis: [
          {
            type: "value",
            // max : 1200,
            // min: 400,
            splitNumber: 4,
            // 去掉刻度
            axisTick: {
              show: false
            },
            bottom: 10,
            // show : false,
            // 去掉y轴坐标线
            axisLine: {
              show: false
            },
            // #0d1b4b
            //网格样式
            splitLine: {
              show: true,
              lineStyle: {
                color: ["#0d1b4b"],
                width: 1,
                type: "solid"
              }
            },
            // 设置字体
            axisLabel: {
              show: true,
              textStyle: {
                color: "#ffffff",
                fontSize: 12
              }
            }
          }
        ]
      }
    };
  },
  components: {
    echarts2
  },
  methods: {
    tabClick(index) {
      this.isActive = index;
    }
  }
};
</script>
<style lang="scss" scoped>
.all {
  width: 100%;
  height: calc(100% - 42px);
  .live-place-container {
    // background: pink;
    width: 100%;
    height: 50%;
    // background: pink;
    /** table tr item start **/
    .title-box {
      display: flex;
      color: #fff;
      padding: 6px 6px;
      box-sizing: border-box;
      justify-content: space-between;
      height: 20px;
      // margin-bottom: 4px;
      .fTab {
        float: right;
        width: 60px;
        height: 12px;
        display: flex;
        border: 0.5px solid #44f0ff;
        border-radius: 3px;
        margin-right: 10px;
        // margin-top: 10px;
        overflow: hidden;
        li {
          width: 40px;
          height: 12px;
          display: flex;
          align-items: center;
          justify-content: center;
          color: #44f0ff;
          font-size: 6px;
          cursor: pointer;
        }
        .seletedTab {
          background: #16416d;
        }
      }
    }
    .tr-item {
      line-height: 15px;
      font-size: 6px;
      background: rgb(3, 35, 80);
      opacity: 0.7;
      margin-bottom: 1px;
      color: #fff;

      .col-3 {
        display: inline-block;
        width: 25%;
        text-align: center;
      }

      &.live-header {
        position: relative;
        opacity: 0.9;
        margin-bottom: 0;

        &:after {
          position: absolute;
          content: "";
          height: 1px;
          left: 0;
          right: 0;
          bottom: -1px;
          background-size: 100% 100%;
          background-image: url("~assets/images/live-header-bg.png");
        }
      }
    }
  }
  .box2 {
    // background: pink;
    width: 100%;
    height: 50%;
  }
}
</style>